<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:t="http://myfaces.apache.org/tomahawk"
                template="/pages/crud_template.xhtml">
                
     <ui:param name="crudBean" value="#{usuarioBean}" />
     
     <ui:define name="content">
     	<!-- Painel de Pesquisa -->
		<h:panelGroup id="panelGroupDePesquisa" rendered="#{crudBean.searching}">
			<f:subview id="viewBusca">
				<table>
					<tr>
						<td class="tdCor" width="120px;"><h:outputText value="Login"/></td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.login}" styleClass="baseField" size="70" maxlength="100" onblur="upperCase(this)"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="Nome"/></td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.nome}" styleClass="baseField" size="70" maxlength="100" onblur="upperCase(this)"/>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
     	<!-- Painel de Atualizacao -->
		<h:panelGroup id="panelGroupDeInsercao" rendered="#{crudBean.updating}">
			<f:subview id="viewInsercao">
				<table>
					<tr>
						<td class="tdCor" width="120px;"><h:outputText value="Login *"/></td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.login}" styleClass="baseField" size="70" maxlength="100" onblur="upperCase(this)"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="Nome *"/></td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.nome}" styleClass="baseField" size="70" maxlength="100" onblur="upperCase(this)"/>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
     </ui:define>
     
     <ui:define name="list">
     	<f:subview id="viewListagem" rendered="#{crudBean.searching}">
			<rich:dataTable id="tblData" value="#{crudBean.searchResult}" binding="#{crudBean.tblData}" var="rst" style="width: 100%;" rowClasses="par,impar">
				<f:facet name="header">
					<rich:columnGroup>
						<rich:column style="text-align: left;">
							<h:outputText value="Nome"/>
						</rich:column>
						<rich:column style="text-align: left;">
							<h:outputText value="Login"/>
						</rich:column>
						<rich:column style="text-align: center;">
						</rich:column>
						<rich:column style="text-align: center;">
						</rich:column>
						<rich:column style="text-align: center;">
						</rich:column>
					</rich:columnGroup>
				</f:facet>
				<rich:column style="text-align: left;">
					<h:outputText value="#{rst.nome}"/>
				</rich:column>
				<rich:column style="text-align: left;">
					<h:outputText value="#{rst.login}"/>
				</rich:column>
				<rich:column style="text-align: center;">
					<a4j:commandButton image="/imagens/senha.png" style="border:white;" title="RESETAR SENHA" actionListener="#{crudBean.resetarSenha}" reRender="formulario" onclick="if (!confirm('Deseja mesmo resetar a senha deste usuário?')) return false" rendered="#{rst.codigo.valor != 1}"/>
				</rich:column>
				<rich:column style="text-align: center;">
					<a4j:commandButton image="/imagens/alterar.png" style="border:white;" title="ALTERAR" actionListener="#{crudBean.preparaAlterar}" reRender="formulario, panelTitle" rendered="#{rst.codigo.valor != 1}"/>
				</rich:column>
				<rich:column style="text-align: center;">
					<a4j:commandButton image="/imagens/inativar.png" style="border:white;" title="INATIVAR" actionListener="#{crudBean.inativar}" reRender="formulario" onclick="if (!confirm('Deseja mesmo inativar este usuário?')) return false" rendered="#{rst.codigo.valor != 1}"/>
				</rich:column>
			</rich:dataTable>
		</f:subview>
     </ui:define>
     
</ui:composition>